#!/bin/sh
DB=school_project
SCHEMA=school_schema
DEFAULT_OUTPUT_PATH=/home/dchernyshov/svntest/nic-practice/2015_chernyshov/school_project/db

OUTPUT_PATH=$1
if [ -z "$1" ]
then
   OUTPUT_PATH=$DEFAULT_OUTPUT_PATH
fi

echo Creating database 'school_project' and user 'head_teacher' with password 'qwerty'
psql -U postgres -f $OUTPUT_PATH/createdb.sql >> result.log 2>> error.log

# �������� ����� ��
echo Restoring structure of schema in database $DB from file $OUTPUT_PATH/"$SCHEMA"_schema.sql >> result.log 2>> error.log
psql -U postgres $DB -f $OUTPUT_PATH/schema.sql >> result.log 2>> error.log

